Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

337
Views
Changing values when a button is pressed, [multiple choices]

I have the following code inside a POST form. When someone clicks on the input the value of pricing changes to the one the user has clicked.

The input class is just a method of altering the CSS once clicked - so you can see which was clicked last.

(function() {
  $(function() {
    var toggle;
    return toggle = new Toggle('.toggle');
  });

  this.Toggle = (function() {
    class Toggle {
      constructor(toggleClass) {
        this.el = $(toggleClass);
        this.tabs = this.el.find(".hs_pricing_toggle");
        this.panels = this.el.find(".panel");
        this.bind();
      }

      show(index) {
        var activePanel, activeTab;
        //update tabs
        this.tabs.removeClass('activate');
        activeTab = this.tabs.get(index);
        $(activeTab).addClass('activate');
        //update panels
        this.panels.hide();
        activePanel = this.panels.get(index);
        return $(activePanel).show();
      }

      bind() {
        return this.tabs.unbind('click').bind('click', (e) => {
          return this.show($(e.currentTarget).index());
        });
      }

    };

    Toggle.prototype.el = null;

    Toggle.prototype.tabs = null;

    Toggle.prototype.panels = null;

    return Toggle;

  }).call(this);

}).call(this);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="hs_pricing_toggle__wrapper" id="toggle__wrapper">
  <input class="price1 hs_pricing_toggle" type="" id="pricing" name="pricing" placeholder="5" value="5" required/>
  <input class="price2 hs_pricing_toggle" type="" id="pricing" name="pricing" placeholder="10" value="5" required/>
  <input class="price3 hs_pricing_toggle" type="" id="pricing" name="pricing" placeholder="15" value="5" required/>
  <input class="price4 hs_pricing_toggle" type="" id="pricing" name="pricing" placeholder="insert value" required/>

This just changes the CSS of the class 'hs_pricing_toggle' and shows a within the class pannel. Nothing important in this case - I guess.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!